//
//  HomeItemHeaderCell.m
//  share_business
//
//  Created by 吴于凌 on 2017/9/2.
//  Copyright © 2017年 wyl. All rights reserved.
//

#import "HomeItemHeaderCell.h"
#import "BSCommon.h"

@interface HomeItemHeaderCell ()


 @property (nonatomic,strong) UILabel *label ;

 @property (nonatomic,strong) UILabel *labelBack ;


@end

@implementation HomeItemHeaderCell


- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        self.backgroundColor = [UIColor colorWithHexString:@"#efefef"];
        
        UIView *line  = [[UIView alloc]initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.frame)-40, 0.5)];
        line.backgroundColor = [UIColor colorWithHexString:@"dddddd"];
        line.centerX = CGRectGetWidth(self.frame)/2 ;
        line.centerY = CGRectGetHeight(self.frame) / 2 ;
        [self addSubview:line] ;
        
        UIView *view = [[UIView alloc]init];
        view.backgroundColor = [UIColor colorWithHexString:@"#efefef"];
        view.tag = 10086 ;
        
        self.label = [[UILabel alloc]init];
        self.label.text = @"生活范";
        [self.label sizeToFit];
        self.label.systemFont = 18 ;
        self.label.x = 0  ;
        self.label.height = CGRectGetHeight(self.frame) ;
        self.label.centerY = CGRectGetHeight(self.frame)/2 + 5 ;
        self.label.textAlignment = NSTextAlignmentCenter ;
        self.label.textColor = RGBA(51, 51, 51, 1);
      
        
        
        self.labelBack = [[UILabel alloc]init];
        self.labelBack.text = @"QUALITY CONTROL";
        [self.labelBack sizeToFit];
        self.labelBack.systemFont = 23 ;
        self.labelBack.x = 0  ;
        self.labelBack.height = CGRectGetHeight(self.frame) - 20 ;
        self.labelBack.centerY = CGRectGetHeight(self.frame)/2 - 5 ;
        self.labelBack.textAlignment = NSTextAlignmentCenter ;
        self.labelBack.textColor = RGBA(229, 228, 229, 1);
        [view addSubview:self.labelBack];
        
        [view addSubview:self.label];
        
        view.height = CGRectGetHeight(self.frame) ;
        view.width = self.labelBack.width + 10;
        view.centerX = CGRectGetWidth(self.frame) / 2;
        view.y = 0 ;
        [self addSubview:view];
    }
    return self;
}

-(void)setType:(NSInteger)type{
    UIView *viewBg = [self viewWithTag:10086 ];
    if (type == 0) {//生活范
        self.label.text = @"生活范";
        self.labelBack.text = @"LIFE STYLE";
     }else if(type == 1){//品质控
        self.label.text = @"品质控";
        self.labelBack.text = @"QUALITY CONTROL";
     }
    float widhtText = [BSCommon calculateRowWidth:self.labelBack.text fontSize:23 maxHeight:70];
    viewBg.width = widhtText + 20 ;
    viewBg.centerX = CGRectGetWidth(self.frame) / 2;
    self.label.width = widhtText ;
    self.label.centerX = viewBg.width / 2;
    self.labelBack.width = widhtText +20;
    self.labelBack.centerX = (widhtText+20) /2  ;
}


@end
